import React, { FC, useEffect, useState } from 'react'
import { Route, RouteProps, useLocation } from 'react-router-dom'

import C from '@/components'

const PrivateRoute: FC<RouteProps> = ({ children, ...rest }) => {
  // const { login } = useAuth()
  const [showConnectModal, setShowConnectModal] = useState(false)
  const location = useLocation()
  // const location = useLocation()
  // const target = {
  //   pathname: '/m/connect',
  //   state: { from: location }
  // }

  useEffect(() => {
    if (!1) setShowConnectModal(true)
  }, [location])

  return (
    <Route
      {...rest}
      render={() =>
        1
          ? (children)
          : (<C.WalletConnectModal show={showConnectModal} login={1} onClose={() => setShowConnectModal(false)} />)
      }
    />
  )
}

export default PrivateRoute
